<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*"%>
<%@ page import="com.dao.StudentDao" %>
<%@ page import="com.bean.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<html>
<head>
    <title>Student List</title>
    <style>
        table {
            width: 80%;
            margin: 0 auto;
            border-collapse: collapse;
        }
        table, th, td {
            border: 1px solid black;
            padding: 10px;
            text-align: center;
        }
        th {
            background-color: #f2f2f2;
        }
        ._Button {
            background-color: #1795bb;
            border-radius: 12px;
            border: none;
            color: white;
            padding: 10px 16px;
            text-align: center;
            text-decoration: none;
            font-size: 16px;
            margin: 0;
            cursor: pointer;
        }
    </style>
</head>
<body>
<table>
    <thead>
    <tr>
        <th>学号</th>
        <th>班级号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>手机号</th>
        <th>修改</th>
        <th>删除</th>
        <th><button class="_Button" style="background: gray" onclick="window.location.href='addStudent.jsp'">添加</button></th>
    </tr>
    </thead>
    <tbody>
    <%
        List<Student> list = StudentDao.getList();
        Iterator<Student> iter = list.iterator();
        while (iter.hasNext()) {
            Student student = iter.next();
    %>
    <tr>
        <td><%= student.getId() %></td>
        <td><%= student.getCno() %></td>
        <td><%= student.getName() %></td>
        <td><%= student.getSex() %></td>
        <td><%= student.getAge() %></td>
        <td><%= student.getPhone() %></td>
        <td><button class="_Button" onclick="window.location.href='upDataStudent.jsp?stu_id=<%=student.getId()%>'">修改</button></td>
        <td><button class="_Button" style="background: red"  onclick="window.location.href='deleteDataStudent.jsp?stu_id=<%=student.getId()%>'">删除</button></td>
    </tr>
    <% } %>
    </tbody>
</table>
</body>
</html>